package com.desay.pangoo.itmt.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import lombok.Data;

/**
 * @author uidq1163 on [2022年12月06日上午10:16:03] <br>
 *         work group Tech classification 技术课题变更审核
 * @Modified By： [修改人] on [修改日期] for [修改说明]
 */
@Entity
@EntityListeners(AuditingEntityListener.class)
@Table(name = "tech_project_info_change")
@Data
public class TechProjectInfoChangeEntity extends BaseEntity implements Serializable {

	private static final long serialVersionUID = -1704355078853071576L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id", columnDefinition = "bigint COMMENT '主键'")
	private Long id;

	@Column(name = "change_fields", nullable = false, columnDefinition = "mediumtext COMMENT '变更字段'")
	private String changeFields;

	@ManyToOne(fetch = FetchType.EAGER, optional = true)
	@JoinColumn(name = "tech_project_id", columnDefinition = "bigint COMMENT '关联的课题ID'")
	@JsonIgnoreProperties({ "parent", "children" })
	private TechProjectInfoEntity techProject;

	@Column(name = "audit_status", nullable = false, columnDefinition = "int(2) COMMENT '审核状态：1待审核，2审核通过，3审核不通过'")
	private Integer auditStatus;

	@Column(name = "audit_comments", nullable = true, columnDefinition = "mediumtext COMMENT '审核意见'")
	private String auditComments;

	@Column(name = "audit_time", nullable = true, columnDefinition = "datetime COMMENT '审核时间'")
	private Date auditTime;

	@Column(name = "auditor", nullable = true, columnDefinition = "varchar(50) COMMENT '审核人员'")
	private String auditor;

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		TechProjectInfoChangeEntity other = (TechProjectInfoChangeEntity) obj;
		if (id == null) {
			if (other.id != null) {
				return false;
			}
		} else if (!id.equals(other.id)) {
			return false;
		}
		return true;
	}
}
